﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cstdx.Proto.Std;

/// <summary>
/// 工厂方法委托，用于创建序列化器和反序列化器
/// </summary>
/// <returns>包含IMarshaler、IUnmarshaler和可能的异常的元组</returns>
public delegate (IMarshaler, IUnmarshaler, Exception) Factory();

/// <summary>
/// 提供序列化功能的接口
/// </summary>
public interface IMarshaler
{
	/// <summary>
	/// 将对象序列化为字节数组
	/// </summary>
	/// <returns>序列化后的字节数组</returns>
	byte[] Marshal();
}

/// <summary>
/// 提供反序列化功能的接口
/// </summary>
public interface IUnmarshaler
{
	/// <summary>
	/// 从字节数组反序列化到对象
	/// </summary>
	/// <param name="data">原始字节数组</param>
	void Unmarshal(byte[] data);
}



